package com.chenjun.web.controller.oa;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chenjun.common.Constant;
import com.chenjun.common.base.ResultDto;
import com.chenjun.common.bean.Pagination;
import com.chenjun.common.model.DataGridModel;
import com.chenjun.common.model.DataGridSortModel;
import com.chenjun.core.service.oa.OaBillAttnDayReportService;
import com.chenjun.core.service.oa.OaBillAttnDetailService;
import com.chenjun.web.controller.BaseController;

/**
 * @Description: 考勤人工补录
 * @author dongyibin
 * @date 2017-8-9 下午8:44:40
 */
@SuppressWarnings("serial")
@Controller
@RequestMapping("artificialRecord")
public class ArtificialRecordController extends BaseController {

	@Autowired
	private OaBillAttnDayReportService dayReportService;
	@Autowired
	private OaBillAttnDetailService detailService;
	
	/**
	 * @Description: 进入考勤人工补录页面
	 * @return
	 * @author dongyibin
	 * @date 2017-8-9 下午8:57:15
	 */
	@RequestMapping("/list.html")
	public String index() {
		return "exceptionAttendance/artificialRecord";
	}
	
	/**
	 * @Description: 取考勤明细表考勤方式为人工补录
	 * @param request
	 * @param model
	 * @return
	 * @author dongyibin
	 * @date 2017-9-14 下午8:36:05
	 */
	@RequestMapping("/search")
	@ResponseBody
	public ResultDto getArtificialRecord(HttpServletRequest request, DataGridModel model){
		ResultDto rtDto = new ResultDto();
		String ids= model.getParams().get("userIds").toString();
		model.getParams().put("userIds", Arrays.asList(ids.split(","))); 
		model.getParams().put("attnTypeId", Constant.ATTENDANCE_STYLE_ARTIFICIAL); // 取考勤方式为人工补录
		model.getSortBy().add(new DataGridSortModel("bill_date", DataGridSortModel.ASC));
		Pagination data = detailService.doPagination(model);
		rtDto.setData(data);
		return rtDto;
	}
	
}
